﻿using System;


namespace epicenter2010.Common
{
	/// <summary>
	/// bstack @ 06/06/2010
	/// Entity base abstract class
	/// </summary>
	/// <typeparam name="TKey"></typeparam> 
	public abstract class EntityBase<TKey>
		where TKey : IEquatable<TKey>
	{
		/// <summary>
        /// Id
        /// </summary>
        public readonly TKey Id;

		/// <summary>
		/// Creation timestamp
		/// </summary>
		public readonly DateTimeOffset CreationTimestamp;


        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="id"></param>
        /// <param name="creationTimestamp"></param>
		protected EntityBase(
            TKey id,
			DateTimeOffset creationTimestamp)
		{
			epicenter2010.Common.DBCChecker.RequireArgument("id", (!id.Equals(default(TKey))), "Invalid argument value", id);
			epicenter2010.Common.DBCChecker.RequireArgument("creationTimestamp", (!creationTimestamp.Equals(default(TKey))),
				"Invalid argument value", creationTimestamp);

			this.Id = id;
			this.CreationTimestamp = creationTimestamp;
		}
    }
}
